package com.liyunc.demo.enums;

/**
 * 枚举一些常用的Api操作码.
 */
public enum ResultCode implements IErrorCode {
    /**
     * 成功.
     */
    SUCCESS(200, "ok"),
    /**
     * 失败.
     */
    FAILED(500, "server error"),
    /**
     * 验证失败.
     */
    VALIDATE_FAILED(401, "validate failed"),
    /**
     * 未登录.
     */
    UNAUTHORIZED(402, "unauthorized"),
    /**
     * 用户名或密码错误.
     */
    USERNAME_OR_PASSWORD_ERROR(405, "username or password error"),
    /**
     * 数据查询错误.
     */
    DATA_NOT_EXIST_ERROR(603, "data not exist"),
    /**
     * 数据添加异常.
     */
    DATA_ADD_ERROR(604, "data add exception"),
    /**
     * 文件上传异常.
     */
    FILE_ERROR(605, "upload error"),
    /**
     * 图片数据查询出现问题.
     */
    IMAGE_ERROR(606, "image error"),
    /**
     * 权限不够.
     */
    FORBIDDEN(403, "forbidden"),
    /**
     * 表单重复提交.
     */
    FROM_REPEAT_SUBMIT(555, "from repeat submit");

    private final long code;
    private final String message;

    ResultCode(long code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public long getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
